package com.ruoyi.system.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.system.mapper.DriverScoreMapper;
import com.ruoyi.system.domain.DriverScore;
import com.ruoyi.system.service.IDriverScoreService;

/**
 * 司机行为分数管理Service业务层处理
 *
 * @author trip
 * @date 2024-09-11
 */
@Service
public class DriverScoreServiceImpl extends ServiceImpl<DriverScoreMapper, DriverScore> implements IDriverScoreService {

    @Autowired
    private DriverScoreMapper driverScoreMapper;

    /**
     * 查询司机行为分数管理
     *
     * @param driverScoreId 司机行为分数管理主键
     * @return 司机行为分数管理
     */
    @Override
    public DriverScore selectDriverScoreByDriverScoreId(Long driverScoreId) {
        return driverScoreMapper.selectDriverScoreByDriverScoreId(driverScoreId);
    }

    /**
     * 查询司机行为分数管理列表
     *
     * @param driverScore 司机行为分数管理
     * @return 司机行为分数管理
     */
    @Override
    public List<DriverScore> selectDriverScoreList(DriverScore driverScore) {
        return driverScoreMapper.selectDriverScoreList(driverScore);
    }

    /**
     * 新增司机行为分数管理
     *
     * @param driverScore 司机行为分数管理
     * @return 结果
     */
    @Override
    public int insertDriverScore(DriverScore driverScore) {
        driverScore.setCreateTime(DateUtils.getNowDate());
        return driverScoreMapper.insertDriverScore(driverScore);
    }

    /**
     * 修改司机行为分数管理
     *
     * @param driverScore 司机行为分数管理
     * @return 结果
     */
    @Override
    public int updateDriverScore(DriverScore driverScore) {
        driverScore.setUpdateTime(DateUtils.getNowDate());
        return driverScoreMapper.updateDriverScore(driverScore);
    }

    /**
     * 批量删除司机行为分数管理
     *
     * @param driverScoreIds 需要删除的司机行为分数管理主键
     * @return 结果
     */
    @Override
    public int deleteDriverScoreByDriverScoreIds(Long[] driverScoreIds) {

        LambdaUpdateWrapper<DriverScore> wrapper;
        for (Long id : driverScoreIds) {
            wrapper = Wrappers.lambdaUpdate(DriverScore.class)
                    .eq(DriverScore::getDriverScoreId, id)
                    .set(DriverScore::getDelFlag, "1");
            super.update(new DriverScore(), wrapper);
        }
        return 1;
    }

    /**
     * 删除司机行为分数管理信息
     *
     * @param driverScoreId 司机行为分数管理主键
     * @return 结果
     */
    @Override
    public int deleteDriverScoreByDriverScoreId(Long driverScoreId) {
        return driverScoreMapper.deleteDriverScoreByDriverScoreId(driverScoreId);
    }
}
